package com.yxhl.zoume.core.coupon.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.yxhl.zoume.core.coupon.fragment.CurrentCouponFragment;
import com.yxhl.zoume.core.coupon.fragment.HistoryCouponFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by vhawk on 2016/11/3.
 */
public class CouponPagerAdapter extends FragmentStatePagerAdapter {

    List<Fragment> couponFragments;

    public CouponPagerAdapter(FragmentManager fm) {
        super(fm);
        initFragment();
    }

    private void initFragment() {
        couponFragments = new ArrayList<>();
        couponFragments.add(CurrentCouponFragment.newInstance());
        couponFragments.add(HistoryCouponFragment.newInstance());
    }

    @Override
    public Fragment getItem(int position) {
        return couponFragments.get(position % 2);
    }

    @Override
    public int getCount() {
        return 2;
    }
}
